package com.theeviljames.coursework.client;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.Socket;

import com.theeviljames.coursework.receiver.Receiver;
import com.theeviljames.coursework.receiver.Sample;


public class RadioListener {

	private Receiver receiver;
	
	public RadioListener(Receiver receiver) {
		this.receiver = receiver;
		try {
			Socket client = new Socket("localhost",7778);
			BufferedReader in  = new BufferedReader(new InputStreamReader(client.getInputStream()));
			while(true){
				String s = in.readLine();
				receiver.addSample(Sample.parseSample(s));
				Thread.yield();
			}
			
		} catch (Exception e) {
			// TODO: handle exception
		}
		
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		RadioListener player = new RadioListener(null);
	}

}
